home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 45
/
Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso
/
Aminet
/
game
/
role
/
ldmud-3.2-bin.lha
/
mud
/
doc
/
efun
/
previous_object
< prev
next >
Wrap
Text File
|
2001-08-06
|
1KB
|
41 lines
SYNOPSIS
object previous_object()
object previous_object(int i)
DESCRIPTION
Returns an object pointer to the object that did a
call_other() to the current object, if any. If that object
is destructed, the function returns 0.
If the optional arg is given, the call_other()s are followed
back i times (i.e. previous_object(2) returns the caller of
the caller). 0 <= i <= caller_stack_depth()-1
There is an important special case: in functions called by
the gamedriver in reaction to some external event (e.g. commands
added by add_action), previous_object() will return this_object(),
but previous_object(0) will return 0.
EXAMPLE
int security() {
object prev;
if(!(prev=previous_object()));
else if(getuid(prev)!=getuid(this_object()));
else if(geteuid(prev)!=geteuid(this_object()));
else return 1;
return 0;
}
void high_sensible_func() {
if(!security())
return;
...
}
This example shows how we can check if the last call to a
function of the current object is secure or if we should abort
execution.
SEE ALSO
call_other(E), this_object(E), this_player(E),
caller_stack(E), caller_stack_depth(E), extern_call(E)